﻿@model SimpleTaskManager.Domain.Entities.Task

@using (Html.BeginForm("AddRequirement", "Task", FormMethod.Post, new { id = "RequirementsForm" }))
{
    int i = 0;
    @Html.ValidationSummary(true)

    foreach (SimpleTaskManager.Domain.Entities.Task task in ViewBag.Siblings)
    {
        if(task.TaskID != Model.TaskID)
        {
            bool isChecked = (Model.Requirements.Any(r => r.TaskID.Equals(task.TaskID))); 
            <div>
                @if(isChecked)
                {
                     <input type="checkbox" value="@task.TaskID.ToString()" name="tasks" id="@("task_"+i.ToString())" checked="checked" />
                }
                else
                {
                     <input type="checkbox" value="@task.TaskID.ToString()" name="tasks" id="@("task_"+i.ToString())"/>
                }
                <label for="@("task_" + i.ToString())" >@(task.Name)</label>
            </div>
            i++;
        }
    }
}
